//! YoshiFlowNewBee.debug.js
//

(function() {

Type.registerNamespace('Yoshi.Pages');

////////////////////////////////////////////////////////////////////////////////
// NewBeeTheme

NewBeeTheme = function NewBeeTheme() {
    /// <field name="newBeePage1Title" type="String" static="true">
    /// </field>
    /// <field name="newBeePage2Title" type="String" static="true">
    /// </field>
    /// <field name="continueBtn" type="String" static="true">
    /// </field>
}


Type.registerNamespace('YoshiFlowNewBee');

////////////////////////////////////////////////////////////////////////////////
// YoshiFlowNewBee.NewBeePage2

YoshiFlowNewBee.NewBeePage2 = function YoshiFlowNewBee_NewBeePage2() {
    YoshiFlowNewBee.NewBeePage2.initializeBase(this);
    new Await().addAw(ss.Delegate.create(this, this.basicBuildAw), 'YesPlayLove Step 1').addDx(ss.Delegate.create(this, function() {
        this.pageCluster.addClass('TrupleCluster');
    })).commit();
}


////////////////////////////////////////////////////////////////////////////////
// NewBeePageBase

NewBeePageBase = function NewBeePageBase() {
    NewBeePageBase.initializeBase(this);
    $('#' + Master.pageMasterId).addClass('NewBeeCluster');
}
NewBeePageBase.prototype = {
    
    createTopBar: function NewBeePageBase$createTopBar() {
        this.topBar = new TopBar(this.element, { links: false });
    }
}


////////////////////////////////////////////////////////////////////////////////
// YoshiFlowNewBee.NewBeePage1

YoshiFlowNewBee.NewBeePage1 = function YoshiFlowNewBee_NewBeePage1() {
    YoshiFlowNewBee.NewBeePage1.initializeBase(this);
    var nextPage = (YoshiFlowNewBee.NewBeePage2).get_fullName();
    var aliasName = 'alias';
    var contBtnName = 'contBtn';
    var questions = 'Questions';
    var q1Name = '';
    var question1 = null;
    var q2Name = '';
    var question2 = null;
    new Await().addAw(ss.Delegate.create(this, this.loadNamespaceCssAw)).addAw(ss.Delegate.create(this, this.basicBuildAw), 'YesPlayLove Step 1').addDx(ss.Delegate.create(this, function() {
        this.pageCluster.addClass('TrupleCluster');
    })).loadJson(questions, 'Scripts/Data/NewBeeQuestions.txt').addDx(ss.Delegate.create(this, function() {
        $("<img width='300'/>").appendTo(this.pageCluster).css({ position: 'absolute', top: -160, left: 460 }).attr('src', 'images/Common/PlayAlias1.png');
        this.viewit('https://docs.google.com/presentation/embed?id=1s48FxzELpi-Thl0smwECUEmIqoVE3Ydwe4W_RzUXSOQ&start=true&loop=true&delayms=7000').appendTo(this.pageCluster).addClass('SlideShow');
        var ct = Object.getKeyCount(Await.fileDictionary(questions));
        var q1 = Math.floor(Math.random() * ct) + 1;
        var q2 = Math.floor(Math.random() * ct) + 1;
        while (q1 === q2) {
            q2 = Math.floor(Math.random() * ct) + 1;
        }
        question1 = Await.vita(questions, q1.toString());
        q1Name = question1['name'];
        question1['hide'] = true;
        question1['question'] = 'Hi %alias%. ' + question1['question'];
        question2 = Await.vita(questions, q2.toString());
        q2Name = question2['name'];
        question2['hide'] = true;
    })).addDx(ss.Delegate.create(this, function() {
        new Await().addAw(ss.Delegate.create(this, this.playAliasAw), { Label: 'Please choose your Play Alias', Validate: false }).addAw(ss.Delegate.create(this, this.multipleChoiceAw), question1).addAw(ss.Delegate.create(this, this.multipleChoiceAw), question2).addEv('aliasKeyDn', function(e) {
            if (e.which === 13) {
                Cluster.elements[contBtnName].endEvent(e).focus().click();
            }
        }).addEv('aliasFocus', function() {
            Cluster.elements[contBtnName].fadeIn();
            if (Cluster.elements[q1Name].is(':visible')) {
                Cluster.truples[q1Name].rewindTo(0);
            }
            if (Cluster.elements[q2Name].is(':visible')) {
                Cluster.truples[q2Name].rewindTo(0);
            }
        }).addDx(ss.Delegate.create(this, function(aw) {
            Cluster.truples[aliasName].inputElement().keydown(aw.events['aliasKeyDn']).focusin(aw.events['aliasFocus']);
            Cluster.elements[q1Name].find('input[type=radio]').click(ss.Delegate.create(this, function() {
                this.animateInAw(Await.get_asyncAw(), q2Name);
            }));
            $('input[type=radio]', Cluster.elements[q2Name]).bind('click', function() {
                Master.GoPage(nextPage);
            });
            Cluster.truples[aliasName].followFocus();
        })).addAw(ss.Delegate.create(this, this.animateInAw), aliasName).addEv('contClick', ss.Delegate.create(this, function(e) {
            if (this.playAliasValidate(e, true)) {
                Cluster.elements[contBtnName].hide();
                this.animateInAw(Await.get_asyncAw(), q1Name);
                var alias = Strings.paraCase(Cluster.truples[aliasName].inputElement().getFValue().toString());
                if (!String.isNullOrEmpty(alias)) {
                    Master.profile.set_myAlias(alias);
                    Cluster.truples[aliasName].inputElement().fValue(Master.profile.get_myAlias());
                    Master.profile.saved(false);
                    Master.profile.saveMyProfileAsync(Await.get_asyncAw(), PkgBase.resultRx);
                }
                this.redrawAw(Await.get_asyncAw(), Cluster.truples[q1Name]);
                (Master.page).showTopUser();
            }
        })).addDx(function(aw) {
            Cluster.elements[contBtnName] = $("<button class='ContinueBtn'/>").appendTo(Cluster.elements[aliasName]).html('continue').click(aw.events['contClick']).hide().fadeIn();
            Cluster.truples[q1Name].recordFrame();
            Cluster.truples[q2Name].recordFrame();
        }).addDx(function() {
            Cluster.truples[aliasName].inputElement().focus();
        }).commit();
    })).commit();
}


NewBeeTheme.registerClass('NewBeeTheme');
NewBeePageBase.registerClass('NewBeePageBase', YoshiFlow);
YoshiFlowNewBee.NewBeePage2.registerClass('YoshiFlowNewBee.NewBeePage2', NewBeePageBase);
YoshiFlowNewBee.NewBeePage1.registerClass('YoshiFlowNewBee.NewBeePage1', NewBeePageBase);
NewBeeTheme.newBeePage1Title = 'YesPlayLove Step 1';
NewBeeTheme.newBeePage2Title = 'YesPlayLove Step 2';
NewBeeTheme.continueBtn = 'continue';
})();

//! This script was generated using Script# v0.7.4.0
